package com.goods.business.converter;

import com.goods.common.model.business.Supplier;
import com.goods.common.vo.business.SupplierVO;
import org.springframework.beans.BeanUtils;
import org.springframework.util.CollectionUtils;

import java.util.ArrayList;
import java.util.List;

public class SupplierConverter {
    public static List<SupplierVO> converterToSupplierVOList(List<Supplier> supplierList) {
        if (!CollectionUtils.isEmpty(supplierList)){
            List<SupplierVO> supplierVOS = new ArrayList<>();
            for (Supplier supplier : supplierList) {
                SupplierVO supplierVO = new SupplierVO();
                BeanUtils.copyProperties(supplier,supplierVO);
                supplierVOS.add(supplierVO);
            }
            return supplierVOS;
        }
        return null;
    }

    public static SupplierVO converterToSupplierVO(Supplier supplier) {
        if (supplier != null){
            SupplierVO supplierVO = new SupplierVO();
            BeanUtils.copyProperties(supplier,supplierVO);
            return supplierVO;
        }
        return null;
    }
}
